﻿@{
    Layout = null;
}
@using PermissionsManager.Model
@{
    var jsondata = ViewBag.jsondata;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="~/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/css/style.css" />
    <link href="~/assets/css/codemirror.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/assets/css/ace.min.css" />
    <link rel="stylesheet" href="~/Widget/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css" />
    <link rel="stylesheet" href="~/assets/css/font-awesome.min.css" />

    <!--[if IE 7]>
      <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
    <![endif]-->
    <!--[if lte IE 8]>
      <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="~/assets/js/jquery.min.js"></script>
    <!-- <![endif]-->
    <!--[if IE]>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
     <![endif]-->
    <!--[if !IE]> -->
    <script type="text/javascript">
        window.jQuery || document.write("<script src='~/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
    </script>
    <!-- <![endif]-->
    <!--[if IE]>
    <script type="text/javascript">
     window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
    </script>
    <![endif]-->
    <script src="~/assets/js/ace-elements.min.js"></script>
    <script src="~/assets/js/ace.min.js"></script>
    <script src="~/assets/js/bootstrap.min.js"></script>
    <script src="~/assets/js/typeahead-bs2.min.js"></script>
    <script type="text/javascript" src="~/Widget/zTree/js/jquery.ztree.all-3.5.min.js"></script>
    <script src="~/js/lrtk.js" type="text/javascript"></script>
    <title>分类管理</title>
</head>

<body>
    <div class=" clearfix">
        <div id="category">
            <div id="scrollsidebar" class="left_Treeview">
                <div class="show_btn" id="rightArrow"><span></span></div>
                <div class="widget-box side_content">
                    <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
                    <div class="side_list">
                        <div class="widget-header header-color-green2">
                            <h4 class="lighter smaller">组列表</h4>
                        </div>
                        <div class="widget-body">
                            <div class="widget-main padding-8">
                                <div id="treeDemo" class="ztree"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!---->
            <iframe ID="testIframe" Name="testIframe" FRAMEBORDER=0 SCROLLING=AUTO SRC="ModuleAdd" class="page_right_style"></iframe>
        </div>
    </div>
    <input type="hidden" name="name" id="classId" value="" />
    <input type="hidden" name="name" id="className" value="" />
    <input type="hidden" name="name" id="remark" value="" />
    <input type="hidden" name="name" id="isEnable" value="" />
    <input type="hidden" name="name" id="sortId" value="" />
    <input type="hidden" name="name" id="parent" value="" />
</body>
</html>

<script type="text/javascript">
    //初始化宽度、高度
    $(".widget-box").height($(window).height());
    $(".page_right_style").width($(window).width() - 220);
    //当文档窗口发生改变时 触发
    $(window).resize(function () {
        $(".widget-box").height($(window).height());
        $(".page_right_style").width($(window).width() - 220);
    })

    /**************/
    var setting = {
        view: {
            dblClickExpand: false,
            showLine: false,
            selectedMulti: false
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "pId",
                rootParentId: ""
            }
        },
        callback: {
            beforeClick: function (treeId, treeNode) {
                var zTree = $.fn.zTree.getZTreeObj("tree");
                $("#classId").val(treeNode.id);
                $("#parent").val(treeNode.pId);
                $("#className").val(treeNode.name);
                $("#remark").val(treeNode.remark);
                $("#sortId").val(treeNode.sortId);
                $("#isEnable").val(treeNode.isEnable);
                $("#testIframe").attr("src", "ModuleAdd");
            }
        }
    };

    var nodes = [];
    $(function () {
        $.ajax({
            type: "post",
            url: "/Module/GetModule",
            dataType: 'json',
            success: function (d) {
                // get the top level nodes
                for (var i = 0; i < d.data.length; i++) {
                    var row = d.data[i];
                    nodes.push({
                        id: row.Id,
                        name: row.Name,
                        pId: row.ParentId,
                        remark: row.Remark,
                        sortId: row.SortId,
                        isEnable: row.IsEnable
                    });
                }

                var t = $("#treeDemo");
                t = $.fn.zTree.init(t, setting, nodes);
                //$("#testIframe").bind("load", loadReady);
                //var zTree = $.fn.zTree.getZTreeObj("tree");
                //zTree.selectNode(zTree.getNodeByParam("id",'11'));
            }
        })

    });
</script>